class StagesController < ApplicationController

  def index
    @project = Project.find(params[:project_id])
  end

  def show
    @stage = Stage.find(params[:id])
    
  end

  def new
    @stage = Stage.new(:project_id => params[:project_id])
  end

  def create
    @stage = Stage.new(params[:stage])
    render :new unless @stage.save
  end

  def edit
    @stage = Stage.find(params[:id])
  end

  def update
    @stage = Stage.find(params[:id])
    render :edit unless @stage.update_attributes(params[:stage])
  end

  def destroy
    @stage = Stage.find(params[:id])
    @stage.destroy if @stage.work_items.empty? and @stage.designer_work_items.empty? and @stage.work_item_types.empty? or @stage.name =~ /克隆/
  end
  
  def clone
    @stage = Stage.find(params[:id])
    @clone = @stage.clone!
  end

end
